package com.heima.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;

/**
 * @author Xxx
 */

@Getter
public enum VendingMachineStatus {
    FROZEN(0, "未投放"),
    NORMAL(1, "运营"),
    REVOKE(3, "撤机");

    @EnumValue
    final int value;
    final String desc;

    VendingMachineStatus(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static VendingMachineStatus of(int value) throws Exception {
        if (value == 0) {
            return FROZEN;
        }
        if (value == 1) {
            return NORMAL;
        }
        if (value == 3) {
            return REVOKE;
        }
        throw new Exception("售货机状态错误");
    }
}
